package com.designMode.builder;

/**
 * 具体建造者
 */
public class SimpleBuilder extends AbsBuilder {
    private String part1;
    private String part2;
    private String part3;

    public AbsBuilder setPart1() {
        part1 = "功能1";
        System.out.println("产品需要功能1");
        return this;
    }

    public AbsBuilder setPart2() {
        part2 = "功能2";
        System.out.println("产品需要功能2");
        return this;
    }

    public AbsBuilder setPart3() {
        part3 = "功能3";
        System.out.println("产品需要功能3");
        return this;
    }


    @Override
    public Product builderProduct() {
        System.out.println("建造者建造产品");
        Product product = new Product();
        if (part1 != null)
            product.addPart(part1);
        if (part2 != null)
            product.addPart(part2);
        if (part3 != null)
            product.addPart(part3);
        return product;
    }
}
